﻿#region File Header
/***********************************************************************
 * Copyright © 2013 Beals Software
 * All Rights Reserved
************************************************************************
Author: Donald Beals
Date: February 4th, 2013
Description: TODO: Write a description of this file here.
****************************** Change Log ******************************
02.04.13 - Created initial file. (dbeals)
***********************************************************************/
#endregion

#region Using Statements
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using GameJolt.Async;
#endregion

namespace GameJolt.Async
{
	/// <summary>
	/// 
	/// </summary>
	public abstract class AsyncRequestBase<TResult>
	{
		#region Properties
		public virtual string GameID
		{
			get;
			set;
		}

		protected virtual string PrivateKey
		{
			get;
			set;
		}
		#endregion

		#region Constructors
		public AsyncRequestBase(string gameID, string privateKey)
		{
			if(!string.IsNullOrWhiteSpace(gameID))
			{
				this.GameID = gameID;
				this.PrivateKey = privateKey;
			}
		}
		#endregion

		#region Methods
		public virtual IAsyncResult Begin(AsyncCallback callback, object asyncState)
		{
			return AsyncHelper.BeginAsyncCall<TResult>(Process, callback, asyncState, this);
		}

		public virtual TResult End(IAsyncResult result)
		{
			return AsyncHelper.EndAsyncCall<TResult>(result);
		}

		public virtual TResult Process(IAsyncResult result)
		{
			return default(TResult);
		}
		#endregion
	}
}